home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cool / ge_cool.lha / GE_COOL2.1 / misc / test / test.C < prev    next >
C/C++ Source or Header  |  1992-04-13  |  2KB  |  71 lines

  1. //
  2. // Copyright (C) 1991 Texas Instruments Incorporated.
  3. //
  4. // Permission is granted to any individual or institution to use, copy, modify,
  5. // and distribute this software, provided that this complete copyright and
  6. // permission notice is maintained, intact, in all copies and supporting
  7. // documentation.
  8. //
  9. // Texas Instruments Incorporated provides this software "as is" without
  10. // express or implied warranty.
  11. //
  12. // Created: LGO 11/27/89 -- Initial design
  13. //
  14.  
  15. #ifndef STREAMH            // If the Stream support not yet defined,
  16. #if defined(DOS) || defined(M_XENIX)
  17. #include <stream.hxx>           // include the Stream class header file
  18. #else
  19. #include <stream.h>        // include the Stream class header file
  20. #endif
  21. #define STREAMH
  22. #endif
  23.  
  24. static int num_test;
  25. static int tests_passed;
  26. static int tests_failed;
  27. static char* test_name;
  28.  
  29. void test_start(char* name = NULL) {
  30.   num_test = 0;
  31.   tests_passed = 0;
  32.   tests_failed = 0;
  33.   test_name = name;
  34.   cout << "-----------------------------------------------------------------------------\n";
  35.   cout << "Start Testing";    
  36.   if (test_name != NULL) cout << " " << test_name;
  37.   cout << ":\n-----------------------------------------------------------------------------\n";
  38.   cout.flush();
  39.  }
  40.  
  41. void test_begin(const char* msg) {
  42.   num_test++;
  43.   cout << form(" Test %03d: %-53s --> ", num_test, msg);
  44.   cout.flush();
  45. }
  46.  
  47. // NOTE: We don't pass in the message (see test_begin) because
  48. //       we want to ensure that the message is printed BEFORE
  49. //       the test is executed.  This way when a test crashes
  50. //       we can tell if it was during a test, or between tests.
  51. void test_perform(int success) {
  52.   if (success) {
  53.     tests_passed++;
  54.     cout << "  PASSED\n";
  55.   } else {
  56.     tests_failed++;
  57.     cout << "**FAILED**\n";
  58.   }
  59.   cout.flush();
  60. }
  61.  
  62. void test_summary() {
  63.   cout << "-----------------------------------------------------------------------------\n";
  64.   if (test_name != NULL) cout << test_name << " ";
  65.   cout << "Test Summary: ";
  66.   cout << tests_passed << " passed, " << tests_failed << " failed";
  67.   if (tests_failed > 0) cout << "\t\t\t*****";
  68.   cout << "\n-----------------------------------------------------------------------------\n";
  69.   cout.flush();
  70. }
  71.